﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using Jumbot.Common;
using Jumbot.DataOper;
namespace JumbotCms.DataObject
{
    /// <summary>
    /// 模块表信息
    /// </summary>
    public class Modules
    {
        private string m_Id = "0";
        private string m_Title = string.Empty;
        private string m_Type = string.Empty;
        private int m_Enabled = 0;
        private int m_Locked = 0;

        public string Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }
        public string Title
        {
            set { m_Title = value; }
            get { return m_Title; }
        }
        public string Type
        {
            set { m_Type = value; }
            get { return m_Type; }
        }
        public int Enabled
        {
            set { m_Enabled = value; }
            get { return m_Enabled; }
        }
        public int Locked
        {
            set { m_Locked = value; }
            get { return m_Locked; }
        }

        public Modules()
        {}
        public void GetAllColumn(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT * FROM [jcms_normal_Modules] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                Id = _id;
                Title = dr["Title"].ToString();
                Type = dr["Type"].ToString();
                Enabled = Validator.StrToInt(dr["Enabled"].ToString(), 0);
                Locked = Validator.StrToInt(dr["Locked"].ToString(), 0);
            }
        }

        public string GetTitle(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Title] FROM [jcms_normal_Modules] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Title"].ToString();
            }
            return string.Empty;
        }
        public string GetType(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Type] FROM [jcms_normal_Modules] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Type"].ToString();
            }
            return string.Empty;
        }
        public int GetEnabled(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Enabled] FROM [jcms_normal_Modules] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["Enabled"].ToString(), 0);
            }
            return 0;
        }
        public int GetLocked(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Locked] FROM [jcms_normal_Modules] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["Locked"].ToString(), 0);
            }
            return 0;
        }

    }
}
